package cn.xuqiudong.backend.module.system.param.controller;

import cn.xuqiudong.backend.base.controller.BaseGenericBackendController;
import cn.xuqiudong.backend.module.system.param.model.SysParameterOption;
import cn.xuqiudong.backend.module.system.param.service.SysParameterOptionService;
import cn.xuqiudong.common.base.model.BaseResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 功能: :参数项选项表 控制层
 *
 * @author Vic.xu
 * @since 2025-04-25 10:11
 */
@RestController
@RequestMapping("/system/paramOption")
public class SysParameterOptionController extends BaseGenericBackendController<SysParameterOptionService, SysParameterOption> {

    /**
     * 根据参数id 查询参数选项
     */
    @GetMapping("/listByParameterId")
    public BaseResponse<List<SysParameterOption>> listByParameterId(int parameterId) {
        SysParameterOption lookup = new SysParameterOption();
        lookup.setParameterId(parameterId);
        lookup.setEnable(true);
        List<SysParameterOption> list = service.list(lookup);
        return BaseResponse.success(list);
    }

    /**
     * 根据参数code 查询参数选项
     */
    @GetMapping("/listByParameterCode")
    public BaseResponse<List<SysParameterOption>> listByParameterId(String parameterCode) {
        SysParameterOption lookup = new SysParameterOption();
        lookup.setParameterCode(parameterCode);
        lookup.setEnable(true);
        List<SysParameterOption> list = service.list(lookup);
        return BaseResponse.success(list);
    }

    /**
     * 根据父亲id 查询子选项
     */
    @GetMapping("/listByPid")
    public BaseResponse<List<SysParameterOption>> listByPid(int pid) {
        SysParameterOption lookup = new SysParameterOption();
        lookup.setPid(pid);
        lookup.setEnable(true);
        List<SysParameterOption> list = service.list(lookup);
        return BaseResponse.success(list);
    }
}
